export default {
    template: `
    <div id="login">
        <h1>login</h1>
        <p><label for="userN">用户：</label><input v-model="username" type="text" id="userN"></p>
        <p><label for="pass">密码：</label><input v-model="password" type="text" id="pass"></p>
        <p><input type="button" value="登录" @click="handleSubmit"></p>
        </div>
    `,
    data() {
        return {
            username: "superadmin",
            password: "superadmin"
        }
    },
    methods:{
        handleSubmit(){
            axios.post("/login", {
                username:this.username,
                password:this.password
            }).then(res=>{
                console.log(res.data);
                if(res.data.code === 1){
                    this.$router.push("/dashboard");
                    console.log("登录成功");
                }

            })
        },

    },
}